@extends('develop.layoutEdit')

@section('css')
    <style>
        .layer-go-back{
            display:none;
        }
    </style>
@endsection

@section('title')
    <li class="cur">
        <span>购物车图标设置</span>
    </li>
@endsection

@section('content')

    <input type="hidden" name="function_id" id="function_id" value="{{ $function_id or ''}}">

    <div class="panel panel-default" style="width:900px;">
        <div class="panel-heading">
            <h3 class="panel-title">商品详情页立即购买按钮</h3>
        </div>
        <div class="panel-body">
            <div class="form-group" id="category_is_show">
                <label class="col-sm-3 control-label"><span class="red pr5">*</span>是否显示：</label>
                <div class="col-sm-9">
                    <div class="layui-form">
                        <input type="radio" name="buy_btn_is_show"  value="1" title="是"  @if( !isset($configure['buy_btn']['is_show']) || $configure['buy_btn']['is_show'] == 1) checked @endif>
                        <input type="radio" name="buy_btn_is_show"  value="0" title="否"  @if( isset($configure['buy_btn']['is_show']) && $configure['buy_btn']['is_show'] == 0) checked @endif>
                    </div>

                </div>
            </div>
        </div>
    </div>

    <div class="panel panel-default" style="width:900px;">
        <div class="panel-heading">
            <h3 class="panel-title">分类页购物车图标</h3>
        </div>
        <div class="panel-body">
            <div class="form-group" id="category_is_show">
                <label class="col-sm-3 control-label"><span class="red pr5">*</span>是否显示：</label>
                <div class="col-sm-9">
                    <div class="layui-form">
                        <input type="radio" name="category_is_show"  value="1" title="是" lay-filter="category" @if( !isset($configure['category']['is_show']) || $configure['category']['is_show'] == 1) checked @endif>
                        <input type="radio" name="category_is_show"  value="0" title="否" lay-filter="category" @if( isset($configure['category']['is_show']) && $configure['category']['is_show'] == 0) checked @endif>
                    </div>

                </div>
            </div>

            <div class="form-group" id="icon-box-1" @if( isset($configure['category']['is_show']) && $configure['category']['is_show'] == 0) style="display:none;" @endif>
            <label class="col-sm-3 control-label"><span class="red pr5">*</span>图标样式：</label>
            <div class="col-sm-9" style="margin-bottom: 15px;">
                <div class="layui-form">

                    <input type="radio" name="category_cart_image"  value="/static/images/m/cart-images/cart-1.png"  title="" @if( !isset($configure['category']['cart_image']) || $configure['category']['cart_image'] == '/static/images/m/cart-images/cart-1.png') checked @endif>
                    <img src="/static/images/m/cart-images/cart-1.png" style="width:30px;height:30px;margin-left: -24px;">
                    <div class="form-inline" style="margin-top:7px;">
                        <input type="radio" name="category_cart_image"  value="/static/images/m/cart-images/cart-2.png"  title="" @if( isset($configure['category']['cart_image']) && $configure['category']['cart_image'] == '/static/images/m/cart-images/cart-2.png') checked @endif>
                        <img src="/static/images/m/cart-images/cart-2.png" style="width:30px;height:30px;margin-left: -24px;">
                    </div>

                </div>
            </div>

        </div>
    </div>
    </div>

    <div class="panel panel-default" style="width:900px;">
        <div class="panel-heading">
            <h3 class="panel-title">搜索页购物车图标</h3>
        </div>
        <div class="panel-body">
            <div class="form-group" id="search_is_show">
                <label class="col-sm-3 control-label"><span class="red pr5">*</span>是否显示：</label>
                <div class="col-sm-9">
                    <div class="layui-form">
                        <input type="radio" name="search_is_show"  value="1" title="是" lay-filter="search" @if( !isset($configure['search']['is_show']) || $configure['search']['is_show'] == 1) checked @endif>
                        <input type="radio" name="search_is_show"  value="0" title="否" lay-filter="search" @if( isset($configure['search']['is_show']) && $configure['search']['is_show'] == 0) checked @endif>
                    </div>

                </div>
            </div>

            <div class="form-group" id="icon-box-2" @if( isset($configure['search']['is_show']) && $configure['search']['is_show'] == 0) style="display:none" @endif>
            <label class="col-sm-3 control-label"><span class="red pr5">*</span>图标样式：</label>
            <div class="col-sm-9" style="margin-bottom: 15px;">

                <div class="layui-form">

                    <input type="radio" name="search_cart_image"  value="/static/images/m/cart-images/cart-1.png"  title="" @if( !isset($configure['search']['cart_image']) || $configure['search']['cart_image'] == '/static/images/m/cart-images/cart-1.png') checked @endif>
                    <img src="/static/images/m/cart-images/cart-1.png" style="width:30px;height:30px;margin-left: -24px;">
                    <div class="form-inline" style="margin-top:7px;">
                        <input type="radio" name="search_cart_image"  value="/static/images/m/cart-images/cart-2.png"  title="" @if( isset($configure['search']['cart_image']) && $configure['search']['cart_image'] == '/static/images/m/cart-images/cart-2.png') checked @endif>
                        <img src="/static/images/m/cart-images/cart-2.png" style="width:30px;height:30px;margin-left: -24px;">
                    </div>

                </div>

            </div>

        </div>
    </div>
    </div>

    <div class="panel panel-default" style="width:900px;">
        <div class="panel-heading">
            <h3 class="panel-title">列表页购物车图标</h3>
        </div>
        <div class="panel-body">
            <div class="form-group" id="list_is_show">
                <label class="col-sm-3 control-label"><span class="red pr5">*</span>是否显示：</label>
                <div class="col-sm-9">

                    <div class="layui-form">
                        <input type="radio" name="list_is_show"  value="1" title="是" lay-filter="list" @if( !isset($configure['list']['is_show']) || $configure['list']['is_show'] == 1) checked @endif>
                        <input type="radio" name="list_is_show"  value="0" title="否" lay-filter="list" @if( isset($configure['list']['is_show']) && $configure['list']['is_show'] == 0) checked @endif>
                    </div>

                </div>
            </div>

            <div class="form-group" id="icon-box-3" @if( isset($configure['list']['is_show']) && $configure['list']['is_show'] == 0) style="display: none;" @endif>
            <label class="col-sm-3 control-label"><span class="red pr5">*</span>图标样式：</label>
            <div class="col-sm-9" style="margin-bottom: 15px;">

                <div class="layui-form">

                    <input type="radio" name="list_cart_image"  value="/static/images/m/cart-images/cart-1.png"  title="" @if( !isset($configure['list']['cart_image']) || $configure['list']['cart_image'] == '/static/images/m/cart-images/cart-1.png') checked @endif>
                    <img src="/static/images/m/cart-images/cart-1.png" style="width:30px;height:30px;margin-left: -24px;">
                    <div class="form-inline" style="margin-top:7px;">
                        <input type="radio" name="list_cart_image"  value="/static/images/m/cart-images/cart-2.png"  title="" @if( isset($configure['list']['cart_image']) && $configure['list']['cart_image'] == '/static/images/m/cart-images/cart-2.png') checked @endif>
                        <img src="/static/images/m/cart-images/cart-2.png" style="width:30px;height:30px;margin-left: -24px;">
                    </div>

                </div>

            </div>

        </div>
    </div>
    </div>

    <div class="form-group">
        <label class="col-sm-3 control-label"></label>
        <div class="col-sm-9">
            <input type="button"  value="保存" onclick="func.edit();" class="btn btn-success" style="margin-left: 18px;">
        </div>
    </div>

@endsection

@section('js')
    <script>

        layui.use(['form'], function() {
            var form = layui.form();

            //监听单选框
            form.on('radio(search)',function(data){

                if ( data.value == 1 ) {
                    $('#icon-box-2').show();
                } else {
                    $('#icon-box-2').hide();
                }

            });
            //监听单选框
            form.on('radio(list)',function(data){

                if ( data.value == 1 ) {
                    $('#icon-box-3').show();
                } else {
                    $('#icon-box-3').hide();
                }

            });
            //监听单选框
            form.on('radio(category)',function(data){

                if ( data.value == 1 ) {
                    $('#icon-box-1').show();
                } else {
                    $('#icon-box-1').hide();
                }

            });

            $(function(){
                $('#icon-box-1').find('.layui-form').find('.layui-unselect').find('span').text('');
                $('#icon-box-2').find('.layui-form').find('.layui-unselect').find('span').text('');
                $('#icon-box-3').find('.layui-form').find('.layui-unselect').find('span').text('');
            });

        });

        var func = {

            function_id : {{ $function_id or ''}},

            //保存
            edit:function(){

                //表单数据
                var dt = E.getFormValues('edit-form');

                var buy_btn = { };
                var category = { };
                var search = { };
                var list = { };
                if( dt.buy_btn_is_show == 1 ){
                    buy_btn.is_show = 1;
                }else{
                    buy_btn.is_show = 0;
                }

                if( dt.category_is_show == 1 ){
                    category.is_show = 1;
                    category.cart_image = dt.category_cart_image;

                }else{
                    category.is_show = 0;
                }

                if( dt.search_is_show == 1 ){
                    search.is_show = 1;
                    search.cart_image = dt.search_cart_image;

                }else{
                    search.is_show = 0;
                }

                if( dt.list_is_show == 1 ){
                    list.is_show = 1;
                    list.cart_image = dt.list_cart_image;

                }else{
                    list.is_show = 0;
                }

                //组装ajax数据
                var configure = { };

                configure.buy_btn = buy_btn;
                configure.category = category;
                configure.search = search;
                configure.list = list;

                configure.function_id = dt.function_id;

                var index  = layer.load() ;
                E.ajax( {
                    type:'get',
                    url: '/lar/develop/function/store/'+func.function_id,
                    data:configure,
                    dataType:'json',
                    // 返回值判断
                    success: function ( obj ){

                        layer.close( index) ;

                        if ( obj.code == 200 ) {
                            layer.alert( obj.message , { icon: 1,time : 1500 } ) ;
                        } else {
                            layer.alert( obj.message , { icon: 2 } ) ;
                        }
                    }
                } ) ;

            }

        };

    </script>

@endsection